#ifndef __I386_STDLIB_H__
#define __I386_STDLIB_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifndef NULL
#define NULL 0L
#endif

#define RAND_MAX 2147483647

typedef unsigned long size_t;

#ifndef __cplusplus
typedef int wchar_t;
#endif

long strtoi(char *s, int base, char **scan_end);
unsigned long strtou(char *s, int base, char **scan_end);
long strtol(const char *nptr, char **endptr, int base);
unsigned long strtoul(const char *nptr, char **endptr, int base);

unsigned dcvt(long long v, char *buffer, int base, int width, int flag);
unsigned ucvt(unsigned long long v, char *buffer, int base, int width, int flag);


#define atoi(s)	strtoi(s, 10, NULL);
#define atou(s)	strtou(s, 10, NULL);
#define atol(s) strtol(s, NULL, 10);

void srand(long int seed);
long int rand(void);
unsigned abs(int x);

void exit(int code);

#if !defined(__max)
#define __max(a,b)  (((a) > (b)) ? (a) : (b))
#endif
#if !defined(max)
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#endif
#if !defined(__min)
#define __min(a,b)  (((a) < (b)) ? (a) : (b))
#endif
#if !defined(min)
#define min(a,b)  (((a) < (b)) ? (a) : (b))
#endif

#ifdef __cplusplus
}
#endif

#endif
